"""
通用响应模型
"""
from pydantic import BaseModel
from typing import Optional, Any
from datetime import datetime
from app.utils.helpers import datetime_to_timestamp

class ApiResponse(BaseModel):
    """通用API响应"""
    success: bool = True
    data: Optional[Any] = None
    message: Optional[str] = None
    timestamp: int = None

    def __init__(self, **data):
        if 'timestamp' not in data:
            data['timestamp'] = datetime_to_timestamp(datetime.now())
        super().__init__(**data)